<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="renderer" content="webkit" />
<link href="../css/bootstrap.min.css" rel="stylesheet" />
<link href="../css/font-awesome.min.css" rel="stylesheet" />
<link href="../css/plugins/chosen/chosen.css" rel="stylesheet" />
<link href="../css/plugins/dataTables/dataTables.bootstrap.css"
	rel="stylesheet" />
<link href="../css/plugins/iCheck/custom.css" rel="stylesheet" />
<link href="../css/plugins/toastr/toastr.min.css" rel="stylesheet" />
<link href="../css/animate.css" rel="stylesheet" />
<link href="../css/style.css" rel="stylesheet" />
</head>
<body class="top-navigation">
	<div id="wrapper">
		<div id="page-wrapper" class="gray-bg dashbard-1">
			<div class="row border-bottom">
				<nav class="navbar navbar-static-top" style="margin-bottom:0">
					<div class="navbar-header">
						<div class="minimalize-styl-2">
							<a class="btn btn-primary" href="main.html"><i
								class="fa fa-home"></i> 主页</a>
							<!-- ++++++++++++++++++++++++++++++++ -->
							<ol id="guide" class="breadcrumb m-l">
								<li><a>调度中心</a></li>
								<li><a>商品调拨</a></li>
								<li><strong>库房商品查询</strong></li>
							</ol>
							<!-- ################################ -->
						</div>
					</div>
					<ul class="nav navbar-top-links navbar-right">
						<li><a href="index.html" title="返回首页"><i
								class="fa fa-home"></i></a></li>
						<li><span class="m-r-sm text-muted welcome-message">欢迎使用Feces物流管理系统</span></li>
					</ul>
				</nav>
			</div>
			<div class="row">
				<div class="col-lg-12">
					<div class="ibox float-e-margins">
						<div class="ibox-title">
							<!-- ++++++++++++++++++++++++++++++++ -->
							<h5>商品概览</h5>
							<!-- ################################ -->
							<div class="ibox-tools">
								<!-- ++++++++++++++++++++++++++++++++ -->
								<a class="collapse-link btn-link btn-xs"> 收起/展开<i
									class="fa fa-chevron-up"></i>
								</a>
								<!-- ################################ -->
							</div>
						</div>
						<div class="ibox-content">
							<table class="table table-striped table-bordered table-hover"
								id="store_record">
								<thead>
									<tr>
										<th>商品代码</th>
										<th>商品名称</th>
										<th>所属库房</th>
										<th>商品存量</th>
									</tr>
								</thead>
								<tbody></tbody>
								<tfoot>
									<tr>
										<th>商品代码</th>
										<th>商品名称</th>
										<th>所属库房</th>
										<th>商品存量</th>
									</tr>
								</tfoot>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script src="../js/jquery-2.1.1.min.js"></script>
	<script src="../js/bootstrap.min.js"></script>
	<script src="../js/plugins/chosen/chosen.jquery.js"></script>
	<script src="../js/plugins/datepicker/bootstrap-datepicker.js"></script>
	<script src="../js/plugins/dataTables/jquery.dataTables.js"></script>
	<script src="../js/plugins/dataTables/dataTables.bootstrap.js"></script>
	<script src="../js/plugins/iCheck/icheck.min.js"></script>
	<script src="../js/plugins/jeditable/jquery.jeditable.js"></script>
	<script src="../js/plugins/metisMenu/jquery.metisMenu.js"></script>
	<script src="../js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
	<script src="../js/plugins/toastr/toastr.min.js"></script>
	<script src="../js/feces.js"></script>
	<script src="../js/plugins/pace/pace.min.js"></script>
	<script>
		$(function() {
			var dataURL = '../api/orders.json';
			var crudURL = '../api/order';
			var convert = function(allocation) {
				return [ order.products[0].product_id,
				         allocation.products[0],
				         allocation.outStorehouse.name,
				         allocation.clientOrder.num
				         ];
			};
			$('#store_record')
					.dataTable(
							{
								ajax : {
									url : dataURL,
									dataSrc : function(response) {
										return response.data.map(convert);
									},
								},
								stateSave : true,
								createdRow : function(row, data, dataIndex) {
									$(row).data({
										id : data[0]
									});
								
								},
								
								
								initComplete : function() {
									$('[data-edit]', this).attr('title',
											'点击以编辑');
									$('[data-edit="text"]', this).editable(
											function(value) {
												// put.apply(this, arguments);
												return value;
											}, {
												submit : '确定',
												cancel : '取消',
												height : '100%'
											});
								}
							});

			/*
			 var put = function(data){
			 $.ajax({
			 type:'PUT',
			 url: crudURL,
			 data: data,
			 success: function(result){
			 if (result.status == 0) {
			 toastr.success('修改成功');
			 } else {
			 toastr.error('修改失败');
			 }
			 },
			 });
			 };
			
			 $('#display').dataTable({
			 ajax: {
			 url: dataURL,
			 dataSrc: function(response){
			 return response.data.map(convert);
			 },
			 },
			 stateSave: true,
			 createdRow: function(row, data, dataIndex){
			 var table = this;
			 var id = $('td:eq(0)', row).text();
			 $('td:eq(1)', row).attr('data-col', 'name').attr('data-edit', '');
			
			 $('td:eq(2)', row).attr('data-col', 'majorType').editable(function(value){
			 put({id: id, column: $(this).attr('data-col'), value: value });
			 return types[value];
			 }, {
			 type: 'select',
			 data: JSON.stringify(types),
			 submit: '确定',
			 cancel: '取消',
			 height: '100%'
			 });
			
			 $('td:eq(3)', row).attr('data-col', 'minorType').editable(function(value){
			 put({id: id, column: $(this).attr('data-col'), value: value });
			 return types[value];
			 }, {
			 type: 'select',
			 data: JSON.stringify(types),
			 submit: '确定',
			 cancel: '取消',
			 height: '100%'
			 });
			
			 $('td:eq(4)', row).attr('data-col', 'unit').attr('data-edit', '');
			 $('td:eq(5)', row).attr('data-col', 'price').attr('data-edit', '');
			 $('td:eq(6)', row).attr('data-col', 'discount').attr('data-edit', '');
			 $('td:eq(7)', row).attr('data-col', 'cost').attr('data-edit', '');
			 $('td:eq(8)', row).attr('data-col', 'type').attr('data-edit', '');
			 $('td:eq(9)', row).attr('data-col', 'supplier').attr('data-edit', '');
			 $('td:eq(10)', row).attr('data-col', 'productor').attr('data-edit', '');
			 $('td:eq(11)', row).attr('data-col', 'period').attr('data-edit', '');
			 $('td:eq(12)', row).attr('data-col', 'returnable').attr('data-edit', '');
			 $('td:eq(13)', row).attr('data-col', 'changable').attr('data-edit', '');
			 $('td:eq(14)', row).attr('data-col', 'remark').attr('data-edit', '');
			
			 $('td:eq(15)', row).append(
			 $('<a></a>').addClass('btn btn-outline btn-danger btn-xs').attr('href', 'javascript:void(0);').text('删 除').click(function(){
			 $.ajax({
			 type: 'DELETE',
			 url: crudURL,
			 data: { id: id, _: Date.now() },
			 success: function(result){
			 if (result.status == 0) {
			 toastr.success('删除成功');
			 table.fnDeleteRow(dataIndex);
			 } else {
			 toastr.error('删除失败');
			 }
			 }
			 });
			 })
			 );
			
			
			
			 $('[data-edit]', row).editable(function(value){
			 put({id: id, column: $(this).attr('data-col'), value: value });
			 return value;
			 },{
			 submit: '确定',
			 cancel: '取消',
			 height: '100%'
			 });
			
			 }
			 });
			 */

			$('.i-checks').iCheck({
				checkboxClass : 'icheckbox_square-green',
				radioClass : 'iradio_square-green',
			});
		});
	</script>
</html>
